import os.path

import pandas as pd

class DataOperation: # Operation 业务
    def __init__(self,path):
        self.data = pd.read_csv(path)

    def get_data_to_list(self):
        return self.data.values.tolist()

    def get_data_to_dict(self):
        # 列表推导式
        return [self.data.loc[i].to_dict() for i in self.data.index.values]

if __name__ == '__main__':
    print(os.path.abspath(__file__)) # 当前文件的路径
    data_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),'data','lj_data.csv')  # 操作文件的路径
    print(data_path)
    # 实例化对象
    do = DataOperation(data_path)
    print(do.get_data_to_list())
    print(do.get_data_to_dict())